package com.ywjt.pinkelephant.util;

import android.content.Context;
import android.content.res.Resources;

/***
 * 反射获取view的工具类
 * ***/
public class Utils {
    private static Resources mResources = null;
    private static String mPackageName = null;

    public static int getIdentifier(Context context, String name) {
        return getIdentifier(context, name, "id");
    }

    private static int getIdentifier(Context context, String name, String defType) {
        if (mResources == null) {
            mResources = context.getResources();
        }
        return mResources.getIdentifier(name, defType, getPackageName(context));
    }

    private static String getPackageName(Context context) {
        if (mPackageName == null) {
            mPackageName = context.getPackageName();
        }
        return mPackageName;
    }
}
